package com.scpii.api.common.auth;

import java.util.Map;

import org.springframework.stereotype.Component;

import com.scpii.api.common.exception.InvalidClientException;

@Component
public class DefaultAuthorizationRequestManager implements
		AuthorizationRequestManager {

	@Override
	public AuthorizationRequest createAuthorizationRequest(
			Map<String, String> authorizationParameters) {
		String appId = authorizationParameters.get("appId");
		
		if (appId == null) {
			throw new InvalidClientException("A appId must be provided");
		}

		DefaultAuthorizationRequest defaultAuthorizationRequest = new DefaultAuthorizationRequest(
				authorizationParameters);
		defaultAuthorizationRequest.addClientAuthorities();
		return defaultAuthorizationRequest;
	}
}
